package cn.shutdown.controller;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.shutdown.user.po.User;
import cn.shutdown.user.service.IUserService;

@Controller
public class GeneralController {
	private static final Logger logger = Logger.getLogger(GeneralController.class);
	
	@Autowired
	private IUserService userService;
	/**
	 * 访问首页用 http://localhost:8080/index.do
	 * @param model
	 * @return
	 */
	@RequestMapping(value="index.do")
	public ModelAndView index_jsp(Model model){
		model.addAttribute("liming","hello liming");
		logger.info("go to index"+new Date());
		ModelAndView mav = new ModelAndView();
	    mav.addObject("contract", "hello liming");
	    mav.addObject("page", "1");
	    return mav;
	}
	
	@RequestMapping(value="getUserJson.do")
	public @ResponseBody User testMyBatisService(Model model, @RequestParam(value="id") int id){
		return userService.getUserById(id);
	}
}
